package entity

import (
	"shqsoft.cn/pasnj/base"
	"time"
)

//TIndiClie 用户
type UserWorkflow struct {
	ID            int          `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	EMID          int          `gorm:"column:EMID"`
	User          User         `gorm:"ForeignKey:EMID"`
	NEWEMID       *int         `gorm:"column:NEWEMID"`
	NewUser       User         `gorm:"ForeignKey:NEWEMID"`
	OUTID         *int         `gorm:"column:OUTID"`
	OOrganization Organization `gorm:"ForeignKey:OUTID"`
	NUTID         int          `gorm:"column:NUTID"`
	NOrganization Organization `gorm:"ForeignKey:NUTID"`
	YJBD          string       `gorm:"column:YJBD"`
	YJBDCaption   string       `gorm:"-"`
	DDDT          time.Time    `gorm:"column:DDDT"`
	JZDT          time.Time    `gorm:"column:JZDT"`
	STEP          int          `gorm:"column:STEP"`
	STEPCaption   string       `gorm:"-"`
	CZRID         int          `gorm:"column:CZRID"`
	STATE         string       `gorm:"column:STATE"`
	ANSTEP        int          `gorm:"column:ANSTEP"`
}

//TableName User用户表名
func (UserWorkflow) TableName() string {
	return "V_SysUser_YGDD_WORKFLOW"
}
func (u *UserWorkflow) AfterFind() (err error) {
	if u.STEP == -1 {
		u.STEPCaption = "不同意"
	} else if u.STEP == 0 {
		u.STEPCaption = "填写申请"
	} else if u.STEP == 1 {
		u.STEPCaption = "复核确认"
	} else {
		u.STEPCaption = "完成"
	}
	if u.YJBD == "1" {
		u.YJBDCaption = "业绩全部带走(含历史)"
	} else if u.YJBD == "2" {
		u.YJBDCaption = "业绩全部留给其他员工"
	} else if u.YJBD == "3" {
		u.YJBDCaption = "业绩全部留给自己"
	} else if u.YJBD == "4" {
		u.YJBDCaption = "业绩部分带走"
	} else if u.YJBD == "5" {
		u.YJBDCaption = "业绩全部带走(不含历史)"
	}
	return
}

func UserWorkflowEF() base.EntityFunc {
	return func() interface{} {
		entity := UserWorkflow{}
		return &entity
	}
}
func UserWorkflowESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []UserWorkflow
		return &entities
	}
}

func init() {
	relationship := []string{"NOrganization", "User", "OOrganization", "NewUser"}
	base.DaoPoolObj.Put("UserWorkflow", base.NewDefaultDao(UserWorkflowEF(), UserWorkflowESF(), relationship))
}
